﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlayerScannerCore.Model
{
    /// <summary>
    /// Represents a base address that can be shifted by an offset. Do not arbitrarily create instances of this class. 
    /// Every instance ever created is stored in a list.
    /// </summary>
    internal class BaseAddress
    {
        private static List<BaseAddress> _allAddresses = new List<BaseAddress>();
        public static void ShiftAllBaseAddressesBy(int offset)
        {
            foreach(var baseAddr in _allAddresses)
                baseAddr.Address += (uint)offset;
        }

        public BaseAddress(uint originalAddress) 
        { 
            Address = originalAddress;
            _allAddresses.Add(this);
        }

        public uint Address { get; private set;}

        /// <summary>
        /// Allows implicit conversion from BaseAddress to int
        /// </summary>
        public static implicit operator uint(BaseAddress baseAddress)
        {
            return baseAddress.Address;
        }
    }
}
